00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 if ( !defined("PATH_TO_ROOT") ) {
00025 define( "PATH_TO_ROOT", "../../../" );
00026 }
00027
00028 require_once (PATH_TO_ROOT."ressourcen/classes/filemanager/class.resource.inc.php");
00029 require_once (PATH_TO_ROOT."ressourcen/classes/archiver/interface.resourcevisitor.inc.php");
00030 require_once (PATH_TO_ROOT."user/classes/class.usertools.inc.php");
00031
00032 class File extends Resource {
00033 protected $origFileName;
00034 protected $type;
00035 protected $size;
00036 protected $counter;
00037 protected $extension;
00038
00039 public function setOrigFileName ( $origFileName ) {
00040 $this->origFileName = $origFileName;
00041 }
00042
00043 public function getOrigFileName() {
00044 return $this->origFileName;
00045 }
00046
00047 public function setType ( $type ) {
00048 $this->type = $type ;
00049 }
00050
00051 public function getType() {
00052 return $this->type;
00053 }
00054
00055 public function getSize() {
00056 return $this->size;
00057 }
00058
00059 public function setSize ( $size ) {
00060 $this->size = $size;
00061 }
00062
00063 public function setCounter ( $counter ) {
00064 $this->counter = $counter ;
00065 }
00066
00067 public function setExtension ( $extension ) {
00068 $this->extension = $extension ;
00069 }
00070
00076 public function getExtension () {
00077 return $this->extension;
00078 }
00079
00080 public function getPathToFile() {
00081 global $settings;
00082
00083 $basedir = PATH_TO_ROOT.$settings["upload_path"].'filemanager/courseID/'.$this->courseID;
00084
00085 $filename = sprintf("%s/%s", $basedir, $this->link);
00086 return $filename;
00087 }
00088
00089 public function isFileVisible() {
00090 global $db;
00091 if (($_SESSION['usergroup'] == STUDENT || $_SESSION['usergroup'] == ALUMNUS || $_SESSION['usergroup'] == SCHUELER || $_SESSION['usergroup'] == GAST) && $this->visibleType != 1 && $_SESSION['userid'] != $this->userID) {
00092
00093 if (!isset($_SESSION["assistent"]) || (isset($_SESSION["assistent"]) && $this->visibleType == 3 && $_SESSION['userid'] != $this->userID)) {
00094 $visible = $db->get_var("SELECT count(*) FROM filevisible WHERE userID='".Data::toMysql( $_SESSION['userid'] )."' AND fileID='". Data::toMysql( $this->fileID )."'");
00095 return ($visible >= 1);
00096 }
00097 }
00098 return true;
00099 }
00100
00101 private function getUserIcons() {
00102 global $VISIBLE_ICONS;
00103 $imgFolder = $this->fileManager->getImgFolder();
00104
00105
00106 if(isset($_SESSION["UserStyle"]) && $_SESSION["UserStyle"] != "fh_yaml")
00107 $EDIT = "<img src='".$imgFolder."edittypes/lock_edit.gif' alt='edit Symbol' />";
00108 else $EDIT = "<img src='".PATH_TO_ROOT."images/transparent.gif' class='icon_lock_edit' alt='edit Symbol' />";
00109
00110
00111 if(isset($_SESSION["UserStyle"]) && $_SESSION["UserStyle"] != "fh_yaml")
00112 $DELETE = "<img src='".$imgFolder."edittypes/lock_delete.gif' alt='delete Symbol' />";
00113 else $DELETE = "<img src='".PATH_TO_ROOT."images/transparent.gif' class='icon_lock_delete' alt='delete Symbol' />";
00114 $FILEVISIBLE = "";
00115 if ($_SESSION['userid'] == $this->userID || $_SESSION['usergroup'] == ADMIN || ($_SESSION["usergroup"] == DOZENT && $_SESSION["course"] > 0)) {
00116
00117
00118 if(isset($_SESSION["UserStyle"]) && $_SESSION["UserStyle"] != "fh_yaml")
00119 $EDIT = "<a title='Dateieigenschaften verändern' href='./edit.php?editID=".$this->fileID."'><img src='".$imgFolder."edittypes/edit.gif' alt='edit Symbol' /></a>";
00120 else $EDIT = "<a title='Dateieigenschaften verändern' href='./edit.php?editID=".$this->fileID."'><img src='".PATH_TO_ROOT."images/transparent.gif' class='icon_edit_file' alt='edit Symbol' /></a>";
00121
00122
00123 if(isset($_SESSION["UserStyle"]) && $_SESSION["UserStyle"] != "fh_yaml")
00124 $DELETE = "<a title='Datei löschen' href='".$this->createLink(1, array('action' => "deleteFile", "actionID" => $this->fileID)) ."'><img src='".$imgFolder."edittypes/delete.gif' alt='delete Symbol' /></a>";
00125 else $DELETE = "<a title='Datei löschen' href='".$this->createLink(1, array('action' => "deleteFile", "actionID" => $this->fileID)) ."'><img src='".PATH_TO_ROOT."images/transparent.gif' class='icon_delete_file' alt='delete Symbol' /></a>";
00126
00127 $visibleIcon = "";
00128
00129 if (isset($this->visibleType) && $this->visibleType >= 1 && $this->visibleType <= 3) {
00130 $visibleIcon = $VISIBLE_ICONS[$this->visibleType];
00131 }
00132 $FILEVISIBLE = "<a title='Sichtbarkeit ändern' href='".$this->createLink(1, array('action' => "setRessourceVisibility", "actionID" => $this->fileID)) ."'>".$visibleIcon."</a>";
00133 }
00134 $copyFile = "";
00135
00136
00137 if(isset($_SESSION["UserStyle"]) && $_SESSION["UserStyle"] != "fh_yaml")
00138 if ( $this->type == "file" ) $copyFile = "<a title='Datei in anderen Kurs kopieren' href='".$this->createLink(1, array('action' => "copyFile", "actionID" => $this->fileID)) ."'><img src='".$imgFolder."edittypes/copy.png' alt='copy Symbol' /></a>";
00139 else if ( $this->type == "file" ) $copyFile = "<a title='Datei in anderen Kurs kopieren' href='".$this->createLink(1, array('action' => "copyFile", "actionID" => $this->fileID)) ."'><img src='".PATH_TO_ROOT."images/transparent.gif' class='icon_copy_file' alt='copy Symbol' /></a>";
00140
00141
00142 if(isset($_SESSION["UserStyle"]) && $_SESSION["UserStyle"] != "fh_yaml")
00143 return "<a title='Dateibeschreibung anzeigen' href='".$this->createLink(1, array('action' => "infoFile", "actionID" => $this->fileID)) ."'><img src='".$imgFolder."edittypes/info.gif' alt='info Symbol' /></a>".$EDIT.$FILEVISIBLE.$DELETE.$copyFile;
00144 else return "<a title='Dateibeschreibung anzeigen' href='".$this->createLink(1, array('action' => "infoFile", "actionID" => $this->fileID)) ."'><img src='".PATH_TO_ROOT."images/transparent.gif' class='icon_info_file' alt='info Symbol' /></a>".$EDIT.$FILEVISIBLE.$DELETE.$copyFile;
00145 }
00146
00147
00148 protected function getContent($url)
00149 {
00150 $session = curl_init();
00151 curl_setopt($session, CURLOPT_URL, $url);
00152 curl_setopt($session, CURLOPT_HEADER, false);
00153 curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
00154 curl_setopt($session, CURLOPT_CONNECTTIMEOUT, 6);
00155 curl_setopt($session, CURLOPT_TIMEOUT, 6);
00156
00157 $response = curl_exec($session);
00158 if (curl_errno($session)!=0) $response = null;
00159
00160 curl_close($session);
00161 return $response;
00162 }
00163
00164
00165
00173 private function getFaviconUrl($url) {
00174 if (strstr($url, "ftp://")) return false;
00175
00176 $url = str_replace("https://", "http://", $url);
00177 $file = $this->getContent($url);
00178 if (is_null($file)) return false;
00179 $lines = explode( "\n", $file );
00180 $tag = $RT = $return = array();
00181 foreach ( $lines as $line ) {
00182
00183 if (eregi("<link(.*)>", $line, $tag)) if (eregi(".*rel=\"SHORTCUT ICON\" (.*)", $tag[1], $RT) || eregi(".*rel=\"icon\" (.*)", $tag[1], $RT)) if (eregi(".*href=\"([^=]*)\"", $RT[1], $return)) break;
00184 }
00185
00186 if (isset($return[1])) return $return[1];
00187 return false;
00188 }
00189
00190 private function remoteFileExists($url) {
00191 $url_p = parse_url($url);
00192 if (isset($url_p["host"])) {
00193 $host = $url_p["host"];
00194 } else {
00195 return false;
00196 }
00197 $errno = 0;
00198 $errstr = "";
00199 $fp = @fsockopen($host, 80, $errno, $errstr, 5);
00200 if (!$fp) {
00201 return false;
00202 } else {
00203 fputs($fp, "HEAD ".$url." HTTP/1.1\r\n");
00204 fputs($fp, "HOST: ".$host."\r\n");
00205 fputs($fp, "Connection: close\r\n\r\n");
00206 $headers = "";
00207 while (!feof($fp)) {
00208 $headers.= fgets($fp, 128);
00209 }
00210 }
00211 fclose($fp);
00212 $arr_headers = explode("\n", $headers);
00213 if (isset($arr_headers[0])) {
00214 if (!substr_count($arr_headers[0], "200 OK")) return false;
00215 foreach($arr_headers as $header) {
00216 $header = strtoupper($header);
00217 if (substr_count($header, "CONTENT-TYPE:") && substr_count($header, "TEXT/HTML")) return false;
00218 }
00219 return true;
00220 }
00221 return false;
00222 }
00223
00224 public function getHTMLString( $statisticView = false, $cssClass = "" ) {
00225 $templateTableRow = ( $statisticView ) ?
00226 new Template( PATH_TO_ROOT . "/ressourcen/templates/filelist_entry_statistic.html" )
00227 : new Template( PATH_TO_ROOT . "/ressourcen/templates/filelist_entry.html" );
00228
00229 $activeFolder = $this->fileManager->getActiveFolder();
00230 $action = $this->fileManager->getAction();
00231 $actionID = $this->fileManager->getActionID();
00232 $imgFolder = $this->fileManager->getImgFolder();
00233
00234 global $VISIBLE_ICONS;
00235
00236 if (($_SESSION['usergroup'] == STUDENT && $this->visibleType != 1 && $_SESSION['userid'] != $this->userID)) {
00237
00238 if (!isset($_SESSION["assistent"]) || (isset($_SESSION["assistent"]) && $this->visibleType == 3 && $_SESSION['userid'] != $this->userID)) {
00239 $visible = $db->get_var("SELECT count(*) FROM filevisible WHERE userID='".$_SESSION['userid']."' AND fileID='".$this->fileID."'");
00240 if ($visible < 1) continue;
00241 }
00242 }
00243 $CELL = $cssClass;
00244
00245
00246 global $db;
00247 $user = $db->get_row("SELECT Vorname, Nachname, gender FROM user WHERE ID='".$this->userID."'");
00248
00249
00250 $courseID = $_SESSION["course"];
00251 $groupName = UserTools::getUserGroupName($this->userID, $courseID);
00252 $userName = $user->Vorname . " " . $user->Nachname . " ($groupName)";
00253
00254
00255
00256 $fileTypeImage = $imgFolder."filetypes/";
00257 if ($this->type == "link") {
00258 $fileTypeImage.= "link.gif";
00259
00260 $url = @parse_url($this->link);
00261 if ($url['scheme'] == '') $url['scheme'] = "http";
00262 if ($url['host'] != '') {
00263 if ($this->remoteFileExists($url['scheme']."://".$url['host']."/favicon.ico")) {
00264 $fileTypeImage = $url['scheme']."://".$url['host']."/favicon.ico";
00265 } elseif ($favicon = $this->getFaviconUrl($url['scheme']."://".$url['host'])) {
00266 $urlTest = @parse_url($favicon);
00267 if (isset($urlTest['scheme']) && $urlTest['scheme'] == '') $favicon = $url['scheme']."://".$url['host'].'/'.$favicon;
00268 if ($this->remoteFileExists($favicon)) $fileTypeImage = $favicon;
00269 }
00270 }
00271 } elseif ($this->type == "file") {
00272 if (file_exists($imgFolder."filetypes/".$this->extension.".gif")) $fileTypeImage.= $this->extension.".gif";
00273 elseif (file_exists($imgFolder."filetypes/".$this->extension.".png")) $fileTypeImage.= $this->extension.".png";
00274 else {$fileTypeImage.= "file.gif";
00275 $this->extension = "file";}
00276 }
00277 $IMG = "<img width='18' height='16' src='".$fileTypeImage."' alt='Dateisymbol' />";
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289 if ($activeFolder < 0 && $this->courseID == 0 && $_SESSION['course'] != 0) $this->name = "".$this->name."<span class='text10'><strong> (Foyer)</strong></span>";
00290
00291
00292 if (isset($_GET['actionID']) && $_GET['actionID'] == $this->fileID) {
00293 $FILESELECT = 'res_fileselect';
00294 $FILE_CLASS = '';
00295 } else {
00296 $FILESELECT = '';
00297 $FILE_CLASS = 'res_file';
00298 }
00299 $FILE_NAME = Data::toHTML($this->name, false);
00300
00301 if ($this->type == 'link') {
00302 $this->size = "Link";
00303 } else {
00304 $this->size = Format::FilesizeStr($this->size);
00305 }
00306
00307 $downloadStats = ( $statisticView ) ? $this->getDownloadStatisticHTML() : "";
00308 $LINK = ( $statisticView ) ? $this->getStatisticLink() : $this->getFileLink();
00309
00310
00311 $userLink = "<a href='".PATH_TO_ROOT."user/homepage.php?user=$this->userID'>".Data::toHTML("$userName", false) ."</a>";
00312 if ($role = RoleArtefacts::getRoleForItem(RESSOURCE, (int)$this->fileID)) {
00313 $userLink.= " (".$role->getPropertiesLink($role->getName($user->gender)) .")";
00314 }
00315 if ($team = TeamArtefacts::getTeamForItem(RESSOURCE, (int)$this->fileID)) {
00316 $userLink.= " (".Data::toHTML($team->getName(), false) .")";
00317 }
00318 $tableData = array();
00319 $tableData["resource"] = $LINK.$IMG. $FILE_NAME . $downloadStats . "</a>";
00320 if ( !$statisticView )$tableData["action"] = $this->getUserIcons();
00321 $tableData["size"] = $this->size;
00322 $tableData["created"] = Output::echoDate("d.m.Y H:i", (int)$this->createTime);
00323 $tableData["owner"] = $userLink;
00324 $tableData["clicks"] = $this->counter;
00325 if ( $statisticView ) {
00326 $courseCount = $db->get_var("SELECT count(*) FROM user_course ".($this->courseID == 0 ? "" : " WHERE courseID='".$this->courseID."' AND userID!=1"));
00327 $klicks = $db->get_var("SELECT DISTINCT count(userID) FROM filelog WHERE fileID='".$this->fileID."' AND userID!=1 GROUP BY fileID");
00328 $prozent = sprintf("%3.2f%%", ($klicks*100) /$courseCount);
00329 $tableData["clicks"] .= "/" . $prozent;
00330 }
00331
00332 $htmlString = "";
00333 eval( $templateTableRow->getTemplate("htmlString") );
00334 if ( $actionID == $this->fileID ) {
00335 if ( $statisticView ) {
00336 if ( $action == "showInfo" ) $htmlString .= $this->getStatisticHTML();
00337 } else {
00338 $htmlString .= $this->getFileOptionHTML( $action );
00339 }
00340 }
00341
00342 return $htmlString;
00343 }
00344
00345 public function getFileOptionHTML( $option ) {
00346 switch ( $option ) {
00347 case "deleteFile":
00348 return $this->getDeleteFileHTML();
00349 case "copyFile":
00350 return $this->getCopyFileHTML();
00351 case "infoFile":
00352 return $this->getDescriptionHTML();
00353 case "setRessourceVisibility":
00354 return "<tr><td colspan='5'>"
00355 .$this->getRessourceVisibilityHTML()
00356 ."</td></tr>";
00357 }
00358 return "";
00359 }
00360
00361 private function getCopyFileHTML() {
00362 $template = new Template(PATH_TO_ROOT . "/ressourcen/templates/copyfile.html");
00363 $courses = RessourcenDB::getUserCourses( $_SESSION['userid'] );
00364 $currentCourse = 0;
00365 $courseOptions = "";
00366 if ( $_SESSION['course'] != 0 ) {
00367 $courseOptions .= "<option value='0'>Foyer</option>\n";
00368 }
00369 foreach($courses as $course) {
00370 if ($currentCourse == $course->ID) {
00371 $courseOptions .= ", ".Data::toHTML($course->ShortName, false);
00372 } else {
00373 if ($currentCourse != 0) $courseOptions .= ")</option>\n";
00374 $courseOptions .= "<option value='".$course->ID."'";
00375 $courseOptions .= ">".Data::toHTML($course->SN." (".$course->ShortName, false);
00376 $currentCourse = $course->ID;
00377 }
00378 }
00379 $courseOptions .= ")</option>\n";
00380 $folderID = $this->fileManager->getActiveFolder();
00381 $fileID = $this->fileID;
00382 $html = "";
00383 eval ( $template->getTemplate( "html" ) );
00384 return $html;
00385 }
00386
00387 private function getFileLink() {
00388 if ($this->type == 'file') {
00389 $LINK = "<a class='file' href='".$this->createLink(0, array("activeFolder" => $this->fileManager->getActiveFolder(), "action" => 'get'.$this->type, 'actionID' => $this->fileID)) ."' title='Dateiname: ".Data::toHTML($this->origFileName, false) ."'>";
00390 } elseif ($this->type == 'link') {
00391 $LINK = "<a class='file' href='".$this->createLink(0, array("activeFolder" => $this->fileManager->getActiveFolder(), "action" => 'get'.$this->type, 'actionID' => $this->fileID)) ."' title='URL: ".Data::toHTML($this->link, false) ."'>";
00392 }
00393 return $LINK;
00394 }
00395
00396 private function getStatisticLink() {
00397 if ($this->type == 'file') {
00398 $LINK = "<a class='file' href='".Filemanager::createLink(0, array("activeFolder" => $this->fileManager->getActiveFolder(), "action" => 'showInfo', 'actionID' => $this->fileID, 'show' => 'down')) ."' title='Dateiname (Studenten heruntergeladen/Gesamt Studenten im Kurs)'>";
00399 } elseif ($this->type == 'link') {
00400 $LINK = "<a class='file' href='".Filemanager::createLink(0, array("activeFolder" => $this->fileManager->getActiveFolder(), "action" => 'showInfo', 'actionID' => $this->fileID, 'show' => 'down')) ."' title='URL: ".Data::toHTML($this->link, false) ."'>";
00401 }
00402 return $LINK;
00403 }
00404
00405 private function getDownloadCount() {
00406 global $db;
00407 if ($this->courseID == 0) {
00408 $count = (int) $db->get_var("SELECT DISTINCT count(filelog.userID) FROM filelog LEFT JOIN user ON (filelog.userID=user.ID) WHERE fileID='".$this->fileID."' AND filelog.userID!=1 group BY fileID");
00409 } else {
00410 $count = (int) $db->get_var("SELECT DISTINCT count(filelog.userID) FROM filelog LEFT JOIN user_course ON (filelog.userID=user_course.userID) WHERE fileID='".$this->fileID."' AND filelog.userID!=1 AND user_course.courseID='".$this->courseID."' group BY fileID");
00411 }
00412 return $count;
00413 }
00414
00415 private function getDownloadStatisticHTML() {
00416 global $db;
00417 $downloadCount = $this->getDownloadCount();
00418 if ($this->courseID == 0) {
00419 $allCount = $db->get_var("SELECT COUNT(*) FROM user WHERE ID!=1");
00420 } else {
00421 $allCount = $db->get_var("SELECT COUNT(*) FROM user_course WHERE courseID='".$file->courseID."' AND userID!=1");
00422 }
00423 return " (".$downloadCount."/".$allCount.")";
00424 }
00425
00426
00427 private function getDeleteFileHTML() {
00428 $template = new Template(PATH_TO_ROOT . "/ressourcen/templates/deletefile.html");
00429 $folderID = $this->fileManager->getActiveFolder();
00430 $fileID = $this->fileID;
00431 $html = "";
00432 eval ( $template->getTemplate( "html" ) );
00433 return $html;
00434 }
00435
00436 private function getDescriptionHTML() {
00437 $bbcode = new BBCode();
00438 if (!$this->description) $this->description = "Keine Beschreibung vorhanden";
00439 return "<tr><td class='res_file-extra' colspan='6'>".$bbcode->parse($this->description) ."</td></tr>";
00440 }
00441
00442 private function getStatisticHTML() {
00443 global $db;
00444 $CELL1 = $CELL = 'tableCellDark';
00445 $CELL2 = 'tableCell';
00446 $html = "";
00447
00448 if ($this->courseID == 0) {
00449 $allCount = $db->get_var("SELECT COUNT(*) FROM user WHERE ID!=1");
00450 $downCount = $db->get_var("SELECT DISTINCT count(userID) FROM filelog WHERE fileID='".$this->fileID."' AND userID!=1 GROUP BY fileID");
00451 } else {
00452 $allCount = $db->get_var("SELECT COUNT(*) FROM user_course WHERE courseID='".$this->courseID."' AND userID!=1");
00453 $downCount = $db->get_var("SELECT DISTINCT count(filelog.userID) FROM filelog LEFT JOIN user_course ON (filelog.userID=user_course.userID) WHERE fileID='".$this->fileID."' AND filelog.userID!=1 AND user_course.courseID='".$this->courseID."' group BY fileID");
00454 }
00455 if ($downCount == "") $downCount = 0;
00456 $notDownCount = $allCount-$downCount;
00457 $html .= "<tr><td class='res_file-extra' colspan='5'>";
00458 $html .= "Anzeigen: ";
00459
00460
00461 $html .= "[ <a href='".Filemanager::createLink(1, array('show' => 'down')) ."'>".($_GET['show'] == 'down' ? "Downloader" : "Downloader") ." (".$downCount.")</a> | ";
00462 $html .= "<a href='".Filemanager::createLink(1, array('show' => 'notDown')) ."'>".($_GET['show'] == 'notDown' ? "Nicht-Downloader" : "Nicht-Downloader") ." (".$notDownCount.")</a> ]";
00463 $html .= " => Gesamt: ".$allCount;
00464 $html .= "<table class='res_statuserlist'><tr><td class='tableCellHead'>Nr.</td><td class='tableCellHead' style='text-align: left;'>Person</td><td class='tableCellHead'>Anzahl</td><td class='tableCellHead' style='text-align: right;'>Letzter Zugriff</td></tr>";
00465 $count = 0;
00466 switch ($_GET['show']) {
00467
00468 case 'down':
00469 $logs = $db->get_results("SELECT DISTINCT userID, date, count(userID) AS klicks FROM filelog WHERE fileID='".$this->fileID."' AND userID!=1 GROUP BY userID ORDER BY userID, date");
00470 if ($logs) foreach($logs as $log) {
00471 $user = $db->get_var("SELECT concat(Nachname,', ',Vorname) AS name FROM user WHERE ID='".$log->userID."'");
00472 if (!isset($user)) continue;
00473 $data[$user][0] = $log->userID;
00474 $data[$user][1] = Data::toHTML($user, false);
00475 $data[$user][2] = $log->date;
00476 $data[$user][3] = $log->klicks;
00477 }
00478 if (!empty($data)) {
00479 ksort($data);
00480 foreach($data as $value) {
00481 $CELL = ($CELL == $CELL1 ? $CELL2 : $CELL1);
00482 $userLink = PATH_TO_ROOT."user/homepage.php?user=".$value[0];
00483 $html .= "<tr><td class='$CELL'>".++$count."</td><td class='$CELL' style='text-align: left;'><a href='$userLink'>".$value[1]."</a></td><td class='$CELL' >".$value[3]."</td><td class='$CELL' style='text-align: right;'>".Date("d.m.Y H:i", (int)$value[2]) ."</td></tr>";
00484 }
00485 }
00486 break;
00487
00488 case 'notDown':
00489 if ($this->courseID == 0) {
00490 $users = $db->get_results("SELECT ID, concat(Nachname,', ',Vorname) AS name FROM user WHERE ID!=1 ORDER BY name");
00491 } else {
00492 $users = $db->get_results("SELECT ID, concat(Nachname,', ',Vorname) AS name FROM user_course LEFT OUTER JOIN user ON (user_course.userID=user.ID) WHERE ID!=1 AND user_course.courseID='".$this->courseID."' ORDER BY name");
00493 }
00494 if ($users) foreach($users as $user) {
00495 $userLink = PATH_TO_ROOT."user/homepage.php?user=".$user->ID;
00496 $log = $db->get_var("SELECT DISTINCT count(filelog.userID) AS klicks FROM filelog LEFT JOIN user_course ON (filelog.userID=user_course.userID) WHERE filelog.userID='".$user->ID."' AND fileID='".$this->fileID."' GROUP BY filelog.userID");
00497 if ($log != 0) continue;
00498 $CELL = ($CELL == $CELL1 ? $CELL2 : $CELL1);
00499 $html .= "<tr><td class='$CELL'>".++$count."</td><td class='$CELL' style='text-align: left;'><a href='$userLink'>".Data::toHTML($user->name, false) ."</a></td><td class='$CELL' >0</td><td class='$CELL' style='text-align: right;'>Nie</td></tr>";
00500 }
00501
00502 break;
00503
00504 case 'all':
00505 if ($this->courseID == 0) {
00506 $users = $db->get_results("SELECT ID, concat(Vorname,' ',Nachname) AS name FROM user ORDER BY name");
00507 } else {
00508 $users = $db->get_results("SELECT ID, concat(Vorname,' ',Nachname) AS name FROM user_course LEFT OUTER JOIN user ON (user_course.userID=user.ID) WHERE user_course.courseID='".$this->courseID."' ORDER BY name");
00509 }
00510 if ($users) foreach($users as $user) {
00511 $CELL = ($CELL == $CELL1 ? $CELL2 : $CELL1);
00512 $userLink = PATH_TO_ROOT."user/homepage.php?user=".$user->ID;
00513 $log = $db->get_row("SELECT DISTINCT count(userID) AS klicks, date FROM filelog WHERE userID='".$user->ID."' AND fileID='".$this->fileID."' GROUP BY userID");
00514 $date = Output::$html .=Date("d.m.Y H:i", (int)$log->date);
00515 if ($log->date == 0) $date = "Nie";
00516 if ($log->klicks == 0) $log->klicks = "0";
00517 $html .= "<tr><td class='$CELL' >".++$count."</td><td class='$CELL' ><a href='$userLink'>".Data::toHTML($user->name, false) ."</a></td><td class='$CELL' >".$log->klicks."</td><td class='$CELL' style='font-size:10px;text-align:right;' >".$date."</td></tr>";
00518 }
00519 break;
00520 }
00521 $html .= "</table></td></tr>";
00522 return $html;
00523
00524 }
00525
00533 public function archiverAccept(ResourceVisitor $visitor, $parentPath = "/") {
00534 assert($visitor instanceof ResourceVisitor);
00535
00536 return $visitor->visit($this, $parentPath);
00537 }
00538 }